<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 100px;
            height: 100px;
        }
        .containter .box{
            background: pink;
            display: block;
        }
        .containter .box1{
            background: skyblue;
            display: none;
        }
        .containter .box2{
            background: yellowgreen;
            display: none;
        }


    </style>
</head>
<body>
    <div class="containter">
        <button>按钮一</button>
        <button>按钮二</button>
        <button>按钮三</button>
        <div class="box"></div>
        <div class="box1"></div>
        <div class="box2"></div>
    </div>
    <script>
        let btns = document.querySelectorAll('.containter button');
        let divs = document.querySelectorAll('.containter div');
        // let tab = new Tab(btns,divs)
        
    btns.forEach(function(item,key){
        item.onclick = function(){
            divs.forEach(function(div,k){
                if(key === k){
                    // 点击按钮的索引,把和按钮索引一样的div显示出来
                    div.style.display = 'block';
                }else{
                    // 把和点击按钮不同的div隐藏起来
                    div.style.display = 'none';
                }
            })
        }
    })
       




        












    </script>
</body>
</html>